/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package interceptor;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Map;
import pojo.User;
/**
 *
 * @author administrator
 */
public class adminInterceptor extends AbstractInterceptor {
    public String intercept(ActionInvocation invocation) throws Exception {
        Map<String,Object> sessionValues = invocation.getInvocationContext()
                .getSession();
        User user = (User) sessionValues.get("user");
        if(user.getRole().getRoleId() != 3)
            return Action.ERROR;
        return invocation.invoke();
    }

}
